<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('客户列表')" />
    <style>
        .select-list li p {
            width: 100px;
        }
    </style>
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <p>客户姓名：</p>
                                <input type="text" name="name"/>
                            </li>
                            <li>
                                <p>手机号：</p>
                                <input type="text" name="telephone"/>
                            </li>
                            <li>
                                <p>标注：</p>
                                <input type="text" name="description"/>
                            </li>
                            <li>
                                <p>业务员：</p>
                                <div class="input-group" style="width: 200px;">
                                    <input id="treeId" name="memberId" type="text" style="display: none;" />
                                    <input class="form-control" type="text" onclick="selectMemberTree()" id="treeName" readonly="true" >
                                    <span class="input-group-addon"><i class="fa fa-search"></i></span>
                                </div>
                            </li>
                            <li>
                                <p>类型：</p>
                                <select name="type" th:with="type=${@dict.getType('custome_type')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <p>客户分类：</p>
                                <select name="classify" th:with="type=${@dict.getType('custome_classify')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <p>标识：</p>
                                <select name="identification" th:with="type=${@dict.getType('custome_identification')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <p>管理员标识：</p>
                                <select name="identificationAdmin" th:with="type=${@dict.getType('custome_identification')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:customer:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:customer:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:customer:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                 <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:customer:export">
                    <i class="fa fa-download"></i> 导出
                 </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:customer:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:customer:remove')}]];
        var typeDatas = [[${@dict.getType('custome_type')}]];
        var relationshipRecordFlag = [[${@permission.hasPermi('system:customer:relationshipRecord')}]];
        var classifyDatas = [[${@dict.getType('custome_classify')}]];
        var identificationDatas = [[${@dict.getType('custome_identification')}]];
        var identificationAdminDatas = [[${@dict.getType('custome_identification')}]];
        var prefix = ctx + "system/customer";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                relationshipRecordUrl: prefix + "/relationshipRecord/{id}",
                shareUrl: prefix + "/share/{id}",
                sortName: "relationTime",
                sortOrder: "desc",
                modalName: "客户",
                columns: [{
                    checkbox: true
                },
                {
                    field : 'id', 
                    title : 'id',
                    visible: false
                },
                {
                    field : 'name', 
                    title : '客户姓名'
                },
                {
                    field : 'telephone', 
                    title : '手机号'
                },
                {
                    field : 'address', 
                    title : '详细地址'
                },
                {
                    field : 'company',
                    title : '公司名称'
                },
                {
                    field : 'area',
                    title : '面积'
                },
                {
                    field : 'type', 
                    title : '类型',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(typeDatas, value);
                    }
                },
                {
                    field : 'classify',
                    title : '客户分类',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(classifyDatas, value);
                    }
                },
                {
                    field : 'identification',
                    title : '标识',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(identificationDatas, value);
                    }
                },
                {
                    field : 'identificationAdmin',
                    title : '管理员标识',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(identificationAdminDatas, value);
                    }
                },
                {
                    field : 'description',
                    title : '标注'
                },
                {
                    field : 'memberName',
                    title : '业务员'
                },
                {
                    field : 'remark', 
                    title : '补充情况'
                },
                {
                    field : 'createTime',
                    title : '创建时间',
                    sortable: true
                },
                {
                    field : 'record',
                    title : '联系记录'
                },
                {
                    field : 'relationTime',
                    title : '跟进时间',
                    sortable: true,
                    visible: false
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a> ');
                        actions.push('<a class="btn btn-primary btn-xs ' + relationshipRecordFlag + '" href="javascript:void(0)" onclick="$.operate.relationshipRecord(\'' + row.id + '\')"><i class="fa fa-plus"></i>联系记录</a> ');
                        actions.push('<a class="btn btn-info btn-xs " href="javascript:void(0)" onclick="$.operate.share(\'' + row.id + '\')"><i class="fa fa-users"></i>共享客户</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        /*业务员-新增-选择父部门树*/
        function selectMemberTree() {
            var options = {
                title: '业务员选择',
                width: "800",
                url: "/system/member" + "/selectMemberTree/" + $("#treeId").val(),
                callBack: doSubmit
            };
            $.modal.openOptions(options);
        }
        function doSubmit(index, layero){
            var body = layer.getChildFrame('body', index);
            $("#treeId").val(body.find('#treeId').val());
            $("#treeName").val(body.find('#treeName').val());
            layer.close(index);
        }
    </script>
</body>
</html>